package com.video.netty.send;

import com.qf.entity.ResultData;
import com.video.commons.sendaop.ISocketSend;
import com.video.entity.Solution;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * 编辑方案，web发送
 * {"id":"modifySolutionTask",
 *      "account":"admin","oldname":"夏季作息",
 *      "newname":"冬季作息", "msgid": "xxxxxxxxxxxxx"}
 * {"id":"modifySolutionTaskResponse","response":"success", "msgid": "xxxxxxxxxxxxx", "status":"succ"}
 * {"id":"modifySolutionTaskResponse","response":"fail", "msgid": "xxxxxxxxxxxxx", "status":"fail"}
 */
@Component
public class ModifySolutionTaskSend extends ISocketSend {

    @Override
    public Map<String, Object> sendMsg(Object... objs) {
        String oldName = (String) objs[0];
        Solution solution = (Solution) objs[1];
        ResultData<Integer> resultData = (ResultData) objs[2];

        if(resultData.getData() > 0){
            Map map = new HashMap();
            map.put("id", "modifySolutionTask");
            map.put("oldname", oldName);
            map.put("newname", solution.getSolutionname());
            return map;
        }

        return null;
    }
}
